package com.cwt_taxi_xa;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.cwt_taxi_xa.db.bll.MessageBiz;
/**
 * 抢答界面
 * @author ferch
 *
 */
public class MessageActivity extends CWTBaseActivity implements OnClickListener{
	private static final String TAG = "Schedule.";
	public TextView message_info,cancel,gotomsg,time;
	private String message;
	private MessageBiz biz;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.schedule);

		biz = new MessageBiz(this);
		message_info = (TextView)this.findViewById(R.id.message_info);
		cancel = (TextView)this.findViewById(R.id.cancel);
		time = (TextView)this.findViewById(R.id.time);
		gotomsg = (TextView)this.findViewById(R.id.gotomsg);

		message = getIntent().getStringExtra("message");
		message_info.setText(message);

		gotomsg.setOnClickListener(this);
		cancel.setOnClickListener(this);
	}

	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}
	@Override
	public void onClick(View view) {
		switch (view.getId()) {
			case R.id.gotomsg:

				if(MessageList.instance !=null){
					MessageList.instance.finish();
				}

				Intent intent = new Intent();
				intent.setClass(MessageActivity.this, MessageList.class);
				startActivity(intent);
				MessageActivity.this.finish();
				break;
			case R.id.cancel:
				MessageActivity.this.finish();
				break;

			default:
				break;
		}
	}

	private Handler handler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			int what = msg.what;
			if (what == 102) {
				int obj = (Integer) msg.obj;
				if(obj < 0){
					finish();
				}
				time.setText(""+obj);
			}
		}
	};

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	@Override
	public void setStatus(int index, boolean status) {
		// TODO Auto-generated method stub

	}

	@Override
	public void sendMsg(int type, Object obj) {
		// TODO Auto-generated method stub

	}
}
